home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / sources.arc / DANG_SRC.LZH / EVENTS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-06  |  5.2 KB  |  176 lines

  1. /*IMPORTANT!!!!!  second to last line of code has return(0) this
  2. disables ecounters!! set to return 1 to enable!!! */
  3. #include<globals2.h>
  4.  
  5. /* This module is really the heart of the program.
  6.     It checks for events after every turn. I.e. 
  7.     encounters, time, food, hp,sp.
  8.  
  9.     It will call many other modlues such as:
  10.  
  11.                          encounter...etc. */
  12.  
  13. char _clock_[] = "2 clock";       /*sound sample */
  14. char thunder[] = "2 thund";
  15. char crow[]    = "2 crow1";
  16.  
  17. int events()
  18.    {
  19. /* GLOBAL variable CURRENT_SKY holds the color of the current sky. */
  20.     
  21.     int check;
  22.     static int semaphore =0;
  23.     static int raining = 0;
  24.     static int condition = 555;      /* variable, if roll a # greater than this, then encounter! */
  25.     static int c_twice=0;        /* set if roll > condition */
  26.  
  27.     /* Weather forecast */
  28.     mssg_count++;  /* inc the mssg count */
  29.     if (mssg_count == 5) {clear_it(); mssg_count=0;}
  30.     if ( weather == 1 && !semaphore) { semaphore=1;/*turn off for now */
  31.                           Dosound( wind_sound );
  32.                           condition= 522; /* probability of encounter is low */}
  33.     if (weather == 4  && !semaphore) {semaphore=1; /* set so we will not enter again, until new weather occurs */
  34.                         raining = 1; 
  35.                         CURRENT_SKY = 0x444;
  36.                         Setcolor(6,0x444);  /* grey sky */
  37.                         Dosound( rain_sound );
  38.                         condition = 380; /* encounter is high! */}
  39.     if (weather == 2 && !semaphore) { Dosound( quiet );}
  40.     if (weather == 3 && !semaphore) { Dosound( quiet );}
  41.     if (weather == 5 && !semaphore) { Dosound( quiet );}
  42.     if (weather == 0 && !semaphore) { Dosound( quiet );}
  43.  
  44.     CURRENT_SOUND = weather;          /* get value of current sound */
  45.  
  46.     check = pos_rnd(30000);
  47.     if( check > 29983)
  48.     {
  49.      check = pos_rnd(1000);
  50.      if(check > 50)
  51.        {
  52.         
  53.         Setcolor(6,change[count]);  /*chane sky back from rainy, gloomy*/
  54.          semaphore = 0;  /* reset so we can enter a sound routine*/
  55.          raining = 0;    /* reset so we can change sky */
  56.          check = pos_rnd(6);      
  57.           weather = check;  /* get the weather */
  58.                             /* 0 = Normal, 1= Windy, 2=Cool, 3=Hot, 4=Rainy, 5 = Cold!, 6 = Overcast*/
  59.        }
  60.     }
  61.     /*keep track of time */
  62.     time++;
  63.     if( !raining )
  64.       Setcolor(6,change[count]);  /*change sky */
  65.  
  66.      /* check to see if your starving.. */
  67.      if(user.hunger_thurst_status[0] > 6) user.hp--;
  68.      if(user.hunger_thurst_status[1] > 6) user.hp--;
  69.  
  70.   
  71.     if(time == HOUR_VALUE)
  72.      {
  73.       time = 0;
  74.       clock++;  /* inc clock if == 12 reset and call invoketsr(clock) */
  75.       if (clock == 12)
  76.        {
  77.  
  78.         clock =1;         /* these two: clock and am_pm tell the TIME OF DAY ! */
  79.         if (am_pm == 1) am_pm = 0; /* if pm then when clock tolls change to am */
  80.         else am_pm = 1; /* else set to pm */
  81.         v_gtext(handle,6,51,"A clock tolls in");
  82.         v_gtext(handle,6,59,"the distance......");
  83.         invoke_tsr( _clock_ );      /*play clock */
  84.         if(CURRENT_SOUND == 1) Dosound( wind_sound );
  85.         if(CURRENT_SOUND == 4) Dosound( rain_sound );
  86.          
  87.           /* reset all active spells!! */
  88.           for(check=0;check<5;check++)
  89.           user.current_spells_active[check] = 0;
  90.           
  91.           /* update hunger/thirst stats */
  92.           user.hunger_thurst_status[0]+=2; /*hunger */
  93.           user.hunger_thurst_status[1]+=2; /* thirst */
  94.         
  95.           /* if cursed... */
  96.           if( user.user_items[16] ) user.inte--;         
  97.        }
  98.       count += way;
  99.         if(count ==12 || count == 1)
  100.        {
  101.         if(am_pm) am_pm = 0;
  102.        else am_pm = 1;
  103.         }
  104.       if(count ==MIN) {way = 1;count =1;}
  105.       if(count ==MAX) {way =-1;count = 12;}  
  106.      
  107.   
  108.      
  109.    /*   if( !raining )
  110.       Setcolor(6,change[count]);*/  /*change sky */
  111.           }/* end of time == hour value */
  112.     /* and food,hp,sp! */
  113.  
  114.  
  115.    /* if raining, play thunder every once and awhile */
  116.    if (raining)
  117.       {
  118.        if( (pos_rnd(1500)) > 1497)    
  119.        {   
  120.         invoke_tsr( thunder );      /*play  */
  121.          Dosound( rain_sound );     /* restore rain sound */
  122.        }
  123.       }
  124.    if((pos_rnd(1500)) > 1497) 
  125.      {
  126.        if((pos_rnd(1500)) > 1497) 
  127.        {
  128.         v_gtext(handle,6,11,"A crow cries in the");
  129.         v_gtext(handle,6,19,"distance...");
  130.         invoke_tsr( crow );      /*play */
  131.         if(CURRENT_SOUND == 1) Dosound( wind_sound );
  132.         if(CURRENT_SOUND == 4) Dosound( rain_sound );
  133.        }
  134.      }
  135.       
  136.       
  137.    
  138.        
  139.  
  140.    if( !raining) CURRENT_SKY = change[count];
  141.     /*check for encounter! */
  142.     check=pos_rnd(condition+10);   /*roll a 1d12....0-11*/
  143.     
  144.  if(char_alive ==0) game_over();      /* for mon_alive to be 0, ALL*/
  145.  
  146.  
  147.  
  148. /* CONDITION GETS LOWER W/NITE AND BAD WEATHER*/
  149.  
  150.  
  151.  
  152.     if(check>condition)       {
  153.        if ( c_twice == 15 )
  154.         {
  155.            c_twice = 0;
  156.            return(1);
  157.          }
  158.     c_twice++;   /* set. next time thru if true the encounter */ 
  159.       } 
  160.    
  161.     return(0);
  162.  
  163.    }
  164.   
  165.  
  166.  
  167.  
  168.  
  169. /**/
  170. compute_time()
  171. {
  172. if(count > 24) count = 1;
  173.  
  174. count++;
  175.  
  176. }